<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .box {
      width: 300px;
      height: 300px;
      background-color: lightcoral;
      font-size: 50px;
      /* 过渡属性 */
      transition: all 0.5s;
    }

    .box2 {
      width: 400px;
      height: 300px;
      border: 4px solid #000;
      margin: 30px auto;
    }
  </style>
</head>
<body>
  <div class="box">123</div>
  <button>btn</button>

  <script>
    // 获取div
    var box = document.querySelector(".box");
    // 获取按钮
    var btn = document.querySelector("button");

    // 给按钮添加点击事件
    btn.onclick = function() {
      // box.style.width = "600px";
      box.style.backgroundColor = "red"
    }
  </script>
</body>
</html>